array-bytes
A Collection of Array/Bytes/Hex Utilities.
Abilities
TryFromHex
trait
- Convert
Hex
toNum
- type
&str -> isize
- type
&str -> i8
- type
&str -> i16
- type
&str -> i32
- type
&str -> i64
- type
&str -> i128
- type
&str -> usize
- type
&str -> u8
- type
&str -> u16
- type
&str -> u32
- type
&str -> u64
- type
&str -> u128
- type
bytes
prefixed functions
- Convert
Bytes
toHex
- type
&[u8] -> String
- type
hex
prefixed functions
- Convert
HexBytes
toHex
- type
&[u8] -> &str
- e.g.
b"0x..." -> "0x..."
- type
- Build fixed length
Array
fromHex
- type
&str -> [u8; N]
- type
- Convert
Hex
toBytes
- type
&str -> Vec<u8>
- type
- Transform
Hex
toT
- type
&str -> T
- e.g.
"0x..." -> [u8; 20] -> H160
- type
slice
prefixed functions
- Build fixed length
Array
fromSlice
- type
&[T] -> [T; N]
- type
- Transform
Slice
toG
- type
&[T] -> G
- e.g.
&[0_u8, ...] -> [u8; 20] -> H160
- type
vec
prefixed functions
- Build fixed length
Array
fromVec
- type
Vec<T> -> [T; N]
- type
- Transform
Vec
toG
- type
Vec<T> -> G
- e.g.
vec![0_u8, ...] -> [u8; 20] -> H160
- type
Serde support (require feature serde
)
#[serde(deserialize_with = "array_bytes::hex_deserialize_n_into")]
- type
S -> T
- e.g.
"0x..." -> H160
- type
#[serde(deserialize_with = "array_bytes::de_hex2num")]
- type
S -> Num
- e.g.
"0xA" -> 10_u32
- type
#[serde(deserialize_with = "array_bytes::de_hex2bytes")]
- type
S -> Vec<u8>
- e.g.
"0x00" -> vec![0_u8]
- type
Benchmark results
:
change:
Change within noise threshold.
encode time:
change:
No change in performance detected.
Found 1 outliers among 100 measurements
1 low mild
to_hex time:
change:
Change within noise threshold.
Found 10 outliers among 100 measurements
10 low mild
hex_string time:
change:
Performance has regressed.
Found 14 outliers among 100 measurements
5 low severe
5 low mild
1 high mild
3 high severe
hex_encode_fallback
time:
change:
Performance has regressed.
Found 2 outliers among 100 measurements
2 low mild
hex2bytes time:
change:
Change within noise threshold.
Found 6 outliers among 100 measurements
5 low mild
1 high severe
hex2bytes_unchecked
time:
change:
No change in performance detected.
Found 6 outliers among 100 measurements
2 low severe
4 low mild
decode time:
change:
Change within noise threshold.
Found 2 outliers among 100 measurements
1 low mild
1 high mild
from_hex time:
change:
No change in performance detected.
Found 9 outliers among 100 measurements
1 low severe
2 low mild
4 high mild
2 high severe
hex_decode time:
change:
Performance has improved.
Found 7 outliers among 100 measurements
2 low mild
2 high mild
3 high severe
hex_decode_unchecked
time:
change:
No change in performance detected.
Found 5 outliers among 100 measurements
1 low mild
3 high mild
1 high severe
hex_decode_fallback
time:
change:
Change within noise threshold.
Found 4 outliers among 100 measurements
4 high mild
bytes2hex time
License
Licensed under either of Apache-2.0 or GPL-3.0 at your option.